<!--
~ Copyright 2018-present Open Networking Foundation
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~     http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<div id="ov-partition">
    <onos-loading [theme]="'light'" [running]="loadingIconShown"></onos-loading>
    <div class="tabular-header">
        <h2>Partitions ({{tableData.length}} total)</h2>
        <div class="ctrl-btns">
            <div class="refresh" (click)="toggleRefresh()">
                <onos-icon classes="{{ autoRefresh?'active refresh':'refresh' }}" iconId="refresh" iconSize="42" toolTip="{{ autoRefreshTip }}"></onos-icon>
            </div>
        </div>
    </div>
    <div class="summary-list">
        <div class="table-header">
            <table onosTableResize>
                <tr>
                    <td colId="name" [ngStyle]="{width: '100px'}" (click)="onSort('name')">Name
                        <onos-icon classes="active-sort" [iconSize]="10" [iconId]="sortIcon('name')"></onos-icon>
                    </td>
                    <td colId="term" [ngStyle]="{width: '100px'}" (click)="onSort('term')">Term
                        <onos-icon classes="active-sort" [iconSize]="10" [iconId]="sortIcon('term')"></onos-icon>
                    </td>
                    <td colId="leader" [ngStyle]="{width: '200px'}" (click)="onSort('leader')">Leader
                        <onos-icon classes="active-sort" [iconSize]="10" [iconId]="sortIcon('leader')"></onos-icon>
                    </td>
                    <td colId="members">Members </td>
                </tr>
            </table>
        </div>
        <div class="table-body">
            <table onosTableResize id-prop="name">
                <tr *ngIf="tableData.length === 0" class="no-data">
                    <td colspan="4">{{ annots.noRowsMsg }}</td>
                </tr>
                <tr *ngFor="let partition of tableData" [ngClass]="{selected: partition.name === selId}">
                    <td [ngStyle]="{width: '100px'}">{{partition.name}}</td>
                    <td [ngStyle]="{width: '100px'}">{{partition.term}}</td>
                    <td [ngStyle]="{width: '200px'}">{{partition.leader}}</td>
                    <td>{{partition.members}}</td>
                </tr>
            </table>
        </div>
    </div>
</div>
